﻿using System;
using System.Data;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Business.Common
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:AlertAreaControl runat=server></{0}:AlertAreaControl>")]
    public class AlertAreaControl : WebControl
    {

        #region ErrorList
        private List<string> _errorList = new List<string>();
        public List<string> ErrorList
        {
            get
            {
                return _errorList;
            }

            set
            {
                _errorList = value;
            }
        }
        #endregion

        #region WarningList
        private List<string> _warningList = new List<string>();
        public List<string> WarningList
        {
            get
            {
                return _warningList;
            }

            set
            {
                _warningList = value;
            }
        }
        #endregion

        #region InfoList
        private List<string> _infoList = new List<string>();
        public List<string> InfoList
        {
            get
            {
                return _infoList;
            }

            set
            {
                _infoList = value;
            }
        }
        #endregion


        protected override void RenderContents(HtmlTextWriter output)
        {
            if (ErrorList.Count == 0 && WarningList.Count == 0 && InfoList.Count == 0) return;
            output.Write("<table cellspacing=\"0\" cellpadding=\"0\" style=\"background-color:#FFFCDF; width:100%\" border=\"0\">");

            foreach (string item in ErrorList)
            {
                output.Write("<tr>");
                output.Write("<td style=\"color:#FF0000\">" + item + "</td>");
                output.Write("</tr>");
            }

            foreach (string item in WarningList)
            {
                output.Write("<tr>");
                output.Write("<td style=\"color:#FF0000\">" + item + "</td>");
                output.Write("</tr>");
            }

            foreach (string item in InfoList)
            {
                output.Write("<tr>");
                output.Write("<td style=\"color:#FF0000\">" + item + "</td>");
                output.Write("</tr>");
            }
            output.Write("</table>");
        }
    }
}